package com.lc.guessTheWords.util;

import android.view.Gravity;
import android.widget.FrameLayout;

import com.feiwo.banner.AdBanner;
import com.lc.guessTheWords.MainActivity;

public class ADHelper {
	private static AdBanner adMogoLayoutCode;
	private static Object syncObj = new Object();

	private ADHelper() {
	}

	public static void initAD() {
		MainActivity.instance.runOnUiThread(new Runnable() {
			@Override
			public void run() {
				synchronized (syncObj) {
					adMogoLayoutCode = new AdBanner(MainActivity.instance);
					FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
							FrameLayout.LayoutParams.FILL_PARENT,
							FrameLayout.LayoutParams.WRAP_CONTENT);
					// 设置广告出现的位置(悬浮于底部)
					params.gravity = Gravity.BOTTOM;
					params.bottomMargin = 0;
					MainActivity.instance.addContentView(adMogoLayoutCode,
							params);
					adMogoLayoutCode.setAppKey("djgYeGNanVWerLTY01R1zG9V");

				}
			}
		});
	}

	public static void showAd() {
//		if (adMogoLayoutCode != null) {
//			MainActivity.instance.runOnUiThread(new Runnable() {
//				@Override
//				public void run() {
//					adMogoLayoutCode.setVisibility(View.VISIBLE);
//				}
//			});
//		}
	}

	public static void hideAd() {
//		if (adMogoLayoutCode != null) {
//			MainActivity.instance.runOnUiThread(new Runnable() {
//				@Override
//				public void run() {
//					adMogoLayoutCode.setVisibility(View.INVISIBLE);
//				}
//			});
//		}
	}

}
